package cn.doitedu.javase.thread;

public class _01_多线程基本练习 {

    public static Integer count = 0;

    public static void main(String[] args) throws InterruptedException {


        // 开启1个线程，将count值执行5000次++
        Thread t1 = new Thread(new AddTask());
        t1.start();

        // 开启1个线程，将count值执行5000次++
        Thread t2 = new Thread(new AddTask());
        t2.start();


        // 打印  count的值
        t1.join();  // 阻塞方法
        t2.join();

        System.out.println(count);


    }

    static class AddTask implements Runnable{
        @Override
        public void run() {
            for(int i=0;i<5000;i++){
                count++;
            }
        }
    }

}



